/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


function validateForm(){
    
    var email  = document.forms["register"]["email"].value;
    var firstName = document.forms["register"]["firstName"].value;
    var lastName = document.forms["register"]["lastName"].value;
    var securityQuestion = document.forms["register"]["securityQuestion"].value;
    var securityAnswer = document.forms["register"]["securityAnswer"].value;
        
    var password = document.forms["register"]["password"].value;
    var retypePassword = document.forms["register"]["retypePassword"].value;
    var birthMonth = document.forms["register"]["birthMonth"].value;
    var birthDay = document.forms["register"]["birthDay"].value;
    var birthYear = document.forms["register"]["birthYear"].value;

    var returnValue = true;
    
                
    if (!validateEmail(email) ){
                    
        document.getElementById("emailError").innerHTML="Email Address not Valid";
        returnValue = false;
    }
    else 
        document.getElementById("emailError").innerHTML="";
    
            
    if (!validateFirstName(firstName) ){
        document.getElementById("firstNameError").innerHTML="First name too short or long";
        returnValue = false;
    }
    else 
        document.getElementById("firstNameError").innerHTML="";
            
    if (!validatelastName(lastName)){
        document.getElementById("lastNameError").innerHTML="Last Name too short or long";
        returnValue = false;
    }
    else 
        document.getElementById("lastNameError").innerHTML="";
        
    if (!validateSecurityQuestion(securityQuestion)){
        document.getElementById("securityQuestionError").innerHTML="Security question too short or long";
        returnValue = false;
    }
    else 
        document.getElementById("securityQuestionError").innerHTML="";
            
    if (!validateSecurityAnswer(securityAnswer)){
        document.getElementById("securityAnswerError").innerHTML="Security answer too short or long";
        returnValue = false;
    }
    else 
        document.getElementById("securityAnswerError").innerHTML="";
            
    if (!validatePassword(password)){
        document.getElementById("passwordError").innerHTML="Password is too short( it must be at least 6 characters long";
        returnValue = false;
                    
    }
    else 
        document.getElementById("passwordError").innerHTML="";
             
    if (!validateRetypePassword(password, retypePassword)){
        document.getElementById("retypePasswordError").innerHTML="Password does not match";
        returnValue = false;
                   
    }
    else 
        document.getElementById("retypePasswordError").innerHTML="";
            
                

    if (!validateBirthDate(birthMonth,birthDay,birthYear)){
                    
        document.getElementById("birthDateError").innerHTML="Pick a date";
        returnValue = false;
                    
    }
    else 
        document.getElementById("birthDateError").innerHTML="";
            
            
    //    if (!validateAll(email, firstName, lastName, SecurityQuestion, securityAnswer, password, retypePassword, birthMonth, birthDay, birthYear)){
    //        return false;
    //    }
    return returnValue;
}